import React,{useState,useEffect} from 'react'
import Header from '../../components/Header/Header'
import GetNew from './components/GetNew/GetNew';
import Banner from './components/Banner/Banner'
import IndexGoods from './components/IndexGoods/IndexGoods'

import { reqgetbanner, reqgetindexgoods, reqgetnew } from "../../http/api";

export default function Home() {
  const [getnew,setNew]=useState([])
  const [banner,setBanner]=useState([])
  const [indexgoods,setIndexgoods]=useState([])
  const [n,setN]=useState(0)

  useEffect(()=>{
    reqgetnew().then(res=>{
      setNew(res.data.list)
    })
  },[])

  useEffect(()=>{
    reqgetbanner().then(res=>{
      setBanner(res.data.list)
    })
  },[])

  useEffect(()=>{
    reqgetindexgoods().then(res=>{
      setIndexgoods(res.data.list)
    })
  },[])

  return (
    <div>
      <Header title='首页'></Header>
      {/* 新人专享 */}
      <GetNew getnew={getnew}></GetNew>
      {/* 轮播图 */}
      <Banner banner={banner}></Banner>
      <IndexGoods indexgoods={indexgoods} n={n} changeN={(v)=>setN(v)} ></IndexGoods>
    </div>
  )
}
